package org.example.lethear.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

/**
 * 悄悄话实体类
 */
@Entity
@Table(name = "whispers")
@Data
@EqualsAndHashCode(callSuper = false)
@EntityListeners(AuditingEntityListener.class)
public class Whisper {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @Column(name = "target_type", nullable = false)
    private Integer targetType; // 1-用户名，2-暗号
    
    @Column(name = "target_value", nullable = false, length = 100)
    private String targetValue;
    
    @Column(name = "sender_id")
    private Long senderId; // 匿名时为NULL
    
    @Column(name = "sender_nickname", length = 50)
    private String senderNickname;
    
    @Column(nullable = false, columnDefinition = "TEXT")
    private String content;
    
    @Column(name = "is_anonymous", columnDefinition = "TINYINT DEFAULT 1")
    private Integer isAnonymous; // 0-实名，1-匿名
    
    @Column(columnDefinition = "TINYINT DEFAULT 1")
    private Integer status; // 0-删除，1-正常，2-审核中
    
    @CreatedDate
    @Column(name = "create_time", nullable = false, updatable = false)
    private LocalDateTime createTime;
    
    // 构造方法
    public Whisper() {}
    
    // 常量定义
    public static final int TYPE_USERNAME = 1;
    public static final int TYPE_SECRET_CODE = 2;
} 